package com.springboot.study.controller;

/**
 * @Author: guodong
 * @Date: 2021/4/25 14:51
 * @Version: 1.0
 * @Description:
 */
import com.springboot.study.aspjectj.LogPrint;
import com.springboot.study.service.BusinessService;
import com.springboot.study.tests.User;
import com.springboot.study.tests.designpattern.adapter1.AnimalHandler;
import com.springboot.study.tests.designpattern.adapter1.Dog;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("ttcontroller")
public class TTController {


    @Autowired
    AnimalHandler<Dog> animalHandler;


    /**
     * BusinessService 使用的原型多例的 则两个是不一样的  使用的是代理模式
     */
    @Autowired
    BusinessService businessService;
    @Autowired
    BusinessService businessService1;



    @RequestMapping("/dogController")
    @ResponseBody
    @LogPrint(desc = "dogController的属性描述")
    public String dogController(){
        Dog dog = new Dog();
        dog.setName("dog");
//        TTController test = (TTController) AopContext.currentProxy();
        animalHandler.handle("dog", dog);
        return "ok";
    }


    @ResponseBody
    @GetMapping("getIpInfo")
    public User getIpInfo(HttpServletRequest request) {
        return businessService.getIpInfo(request, 0);
    }


}
